<template>

  <Tooltip :title="tip">
    <span><a @click="handleResetCode" :class="{'a-none': able}">
      <!-- <ReloadOutlined :spin="spin" /> -->
      <i class="vxe-icon-refresh"></i>
    </a></span>
  </Tooltip>
  
</template>

<script lang="ts" name="GoodsModal" setup>
import {ref,} from 'vue';
import {Tooltip,} from 'ant-design-vue';
import {resetCode,} from '/@/api/code/code';

const props = defineProps({
  codeKey: {type: Number, default: 0,},
})

const emits = defineEmits(['reset-code'])

const able = ref(false)
const wait = ref(6)
const tip = ref(`重置编号：每隔${wait.value}秒才能点击`)
const handleResetCode = () => {
  if (!able.value) {
    able.value = true
    resetCode({key: props.codeKey as any}).then(dd => {
      emits('reset-code', dd)
    }).finally(() => {
      setTimeout(() => able.value = false, wait.value * 1000)
    })
  }
}

</script>
<style scoped>
.a-none {
  /* pointer-events: none; */
  opacity: .3;
}
</style>
